Skip to content

Conversation

@shellmayr
Copy link
Member

@shellmayr shellmayr commented Oct 21, 2025

Closes TET-1208

@linear
Copy link

linear bot commented Oct 21, 2025

@shellmayr shellmayr marked this pull request as ready for review October 24, 2025 07:32
@shellmayr shellmayr requested a review from a team as a code owner October 24, 2025 07:32
SPANDATA.GEN_AI_REQUEST_MESSAGES,
messages_data,
unpack=False,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing Data Normalization in Agent Span

The invoke_agent_span function is missing a call to _normalize_data() before passing normalized_messages to truncate_and_annotate_messages(). This differs from utils.py and means the truncation function receives Python objects instead of the expected serialized data, preventing it from working correctly. _normalize_data also needs to be imported.

Fix in Cursor Fix in Web

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.94%. Comparing base (dcd94ed) to head (5a16b2e).
⚠️ Report is 10 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...k/integrations/openai_agents/spans/invoke_agent.py 75.00% 0 Missing and 1 partial ⚠️
sentry_sdk/integrations/openai_agents/utils.py 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4968      +/-   ##
==========================================
- Coverage   83.96%   83.94%   -0.03%     
==========================================
  Files         165      178      +13     
  Lines       17073    17842     +769     
  Branches     2999     3172     +173     
==========================================
+ Hits        14336    14978     +642     
- Misses       1839     1900      +61     
- Partials      898      964      +66     
Files with missing lines Coverage Δ
...k/integrations/openai_agents/spans/invoke_agent.py 86.11% <75.00%> (-1.77%) ⬇️
sentry_sdk/integrations/openai_agents/utils.py 87.64% <83.33%> (-0.46%) ⬇️

... and 20 files with indirect coverage changes

Comment on lines +1147 to +1157
# Just verify that messages are being set and truncation is applied
# The actual truncation behavior is tested in the ai_monitoring tests
ai_client_span = ai_client_spans[0]
if "gen_ai.request.messages" in ai_client_span["data"]:
messages_data = ai_client_span["data"]["gen_ai.request.messages"]
assert isinstance(messages_data, str)

parsed_messages = json.loads(messages_data)
assert isinstance(parsed_messages, list)
# Verify messages were processed
assert len(parsed_messages) >= 1
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this checking that truncation is applied?

I would have thought len(parsed_messages) >= 1 is always true, even without truncation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants